<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@page import="tm.data.ProjectsDao" %>
<%@page import="tm.data.DaoFactory" %>
<%@page import="tm.dto.Projects" %>
<%@page import="java.util.List" %>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>Projects Administration</title>
</head>
<body bgcolor="white">
	<h3>Projects:</h3>
	<%
	    /*
	    * This code will generate a list of objects from the
	    * database and place a reference to this list in the
	    * request object.
	    *
	    */
	    ProjectsDao projDao = DaoFactory.getInstance().getProjectsDao();
		List projList = projDao.findAll();
		request.setAttribute("projects", projList);
	%>

	<p>List of Projects in database.</p>
	<table border=1>
		<!-- This code will iterate over the list of items, creating a table row for each item. -->
		<th>Project Id</th><th>Project Name</th><th>Project Description</th>
		<logic:iterate id="element" name="projects" scope="request" type="tm.dto.Projects" >
			<tr>
				<td><bean:write name="element" property="projectId" /></td> 
			    <td><bean:write name="element" property="projectName" /></td> 
				<td><bean:write name="element" property="projectDescription" /></td>	
			</tr>	
		</logic:iterate>
	</table>	

<!-- This form will post the submitted data to the addItem Action Mapping -->	
	<html:form action="/addProjects" method="post">
			<table border=1>
				<tr><td>Project Id:</td><td><html:text property="projectId" /></td>
				<tr><td>Project Name:</td><td><html:text property="projectName" /></td>
				<td>Project Description:</td><td><html:text property="projectDescription" /></td></tr>
			</table>
			<br/>
		<html:submit />
	</html:form>


</body>

</html>